import Router from '@koa/router'
import koaBodyParser from 'koa-bodyparser'
import userService from '@test/service/UserService'
import {ParamException} from "@test/common/HandleException";


let loginRouter = new Router({
    prefix: '/api'
})

loginRouter.post('/login', koaBodyParser(), async ctx => {
    //console.log(ctx.request.query)
    // ctx.body = ctx.render(await userService.login(ctx.request.query))

    ctx.body = await userService.login(ctx.request.query)

})

loginRouter.get('/user', koaBodyParser(), async ctx => {
    //console.log(await userService.findById(ctx.request.query.id))
    console.log(ctx.request.body)
    ctx.body = await userService.findById(ctx.request.query.id)
})

export default loginRouter
